home *** CD-ROM | disk | FTP | other *** search
- ' *****************
- ' *** START.GFA ***
- ' *****************
- ' *** this program runs in High or Medium resolution
- ' *** 'Shell'-program for running *.GFA-programs (must be in main directory)
- ' *** GFA-programs should exit with CHAIN "\START.GFA"
- ' *** © Han Kempen (22-4-1990)
- '
- DEFWRD "a-z"
- '
- start$="\START.INF" ! last path saved here
- scrn.col.max&=80 ! screenwidth 80 characters
- '
- CLS
- ' @check.boot ! check for boot-virus (not activated)
- @high.med.mode ! check resolution : quit if Low rez
- '
- drive$=CHR$(65+GEMDOS(25)) ! problem : this is the GFABASIC.PRG-drive !
- '
- bytes%=DFREE(0) ! slow on harddisk (unless FATSPEED installed)
- current$="p "+drive$+" q "+STR$(bytes%)+" bytes free"
- '
- IF EXIST(start$)
- OPEN "I",#1,start$ ! last accessed folder in file START.INF
- INPUT #1,path$
- CLOSE #1
- ELSE
- path$=drive$+":"+"\" ! main directory
- ENDIF
- '
- IF XBIOS(4)=2
- high.res!=TRUE
- y.fac&=1
- ELSE
- med.res!=TRUE
- y.fac&=2 ! half as many y-pixels in medium resolution
- ENDIF
- '
- IF high.res!
- VSETCOLOR 1,0 ! black letters on white background
- ELSE
- @standard.med.colors
- ENDIF
- '
- IF PEEK(&H444)<>0 ! first time after reset ? (not perfect !)
- IF med.res!
- SPOKE &HFF820A,252 ! * NOT * if you use a TV through a modulator !
- PRINT
- PRINT " Vertical frequency now 60 Hz"
- ENDIF
- '
- SPOKE &H444,0
- PRINT
- PRINT " Write Verify Test switched off"
- '
- IF VAL(RIGHT$(DATE$,2))<88 ! date not set ? (not perfect either)
- HIDEM
- LOCATE 1,9
- PRINT @center$("START-SHELL")
- LOCATE 1,17
- PRINT @center$("GFA-BASIC 3.0")
- DEFLINE 1,5
- RBOX 22*8,10*16/y.fac&,58*8,15*16/y.fac&
- LOCATE 25,12
- @start.date.input
- LOCATE 25,14
- @start.time.input ! just press <Return> if you don't care
- DEFLINE 1,1
- SHOWM
- ENDIF
- '
- ENDIF
- '
- SELECT DPEEK(&H4A6) ! first check if two drives connected
- CASE 1
- drive$="A "
- CASE 2
- drive$="A B "
- ENDSELECT
- FOR n&=2 TO 15 ! now check other drives (harddisk, RAM-disk)
- IF BTST(BIOS(10),n&)
- drive$=drive$+CHR$(n&+65)+" "
- ENDIF
- NEXT n&
- '
- CLS
- left$="START - SHELL"
- DEFTEXT ,2,900,32
- TEXT 100,350/y.fac&,300/y.fac&,left$
- right$="GFA-BASIC 3.0"
- DEFTEXT ,,2700
- TEXT 540,50/y.fac&,300/y.fac&,right$
- DEFTEXT ,0,0,13
- bottom$="drives: "+drive$+" "+current$
- PRINT AT(1,25);@center$(bottom$);
- '
- m$="Choose *.GFA-file <Cancel> = Quit"
- REPEAT
- @fileselect(path$+"*.GFA","",m$,file$)
- UNTIL file$="" OR RIGHT$(file$)="\" OR RIGHT$(file$,4)=".GFA"
- '
- CLS
- IF file$="" OR RIGHT$(file$)="\"
- ' *** user wants to quit
- IF EXIST(start$)
- KILL start$ ! kill file START.INF
- ENDIF
- SETMOUSE 320,200/y.fac&+26
- m$="|Go to GFA-editor| or|return to Desktop ?"
- ALERT 3,m$,1,"EDIT|DESK",k&
- IF k&=1
- NEW
- ELSE
- SYSTEM
- ENDIF
- ELSE
- ' *** user chose GFA-program
- @parse.filename(file$,d$,p$,f$,e$)
- path$=d$+":"+p$
- OPEN "O",#1,start$
- PRINT #1,path$ ! remember last path
- CLOSE #1
- CHDRIVE path$
- CHDIR path$ ! essential for Standard Procedure Get.path in file$ !!
- CHAIN file$ ! start the GFA-program
- ENDIF
- '
- ' ------------------------------------------------------------------------------
- '
- DEFFN center$(text$)=SPACE$((scrn.col.max&-LEN(text$))/2)+text$
- '
- > PROCEDURE check.boot
- ' *** compute checksum of bootsector and warn user if bootsector executable
- LOCAL drive&,buffer$,buffer%,sum%,n&,m$
- PRINT " Checking boot-sector ..."
- drive&=GEMDOS(&H19)
- buffer$=SPACE$(512)
- buffer%=VARPTR(buffer$)
- ~BIOS(4,0,L:buffer%,1,0,drive&) ! bootsector (0) of current drive in buffer
- sum%=0
- FOR n&=0 TO 255
- ADD sum%,CARD{buffer%+n&*2}
- NEXT n&
- sum%=sum% AND &HFFFF
- IF sum%=&H1234
- m$="Bootsector|executable :|this could be|a boot-virus"
- ALERT 3,m$,2," OK |STOP",k&
- ENDIF
- RETURN
- ' **********
- '
- > PROCEDURE high.med.mode
- LOCAL m$,button&
- IF XBIOS(4)=0
- SOUND 1,10,12,4,25
- SOUND 1,10,6,4,25
- SOUND 1,10,12,4,50
- SOUND 1,0
- m$="Sorry, use|High or Medium|resolution for|this program"
- ALERT 3,m$,1," OK ",button&
- IF EXIST(interpreter$)
- EDIT
- ELSE
- SYSTEM
- ENDIF
- ENDIF
- RETURN
- ' **********
- '
- > PROCEDURE get.path(VAR default.path$)
- ' *** return default path (current drive and folder)
- ' *** example - A:\GAMES\
- LOCAL default.drive&,default.drive$
- CLR default.path$
- default.drive&=GEMDOS(&H19)
- default.drive$=CHR$(default.drive&+65)
- default.path$=DIR$(default.drive&+1)
- IF default.path$<>""
- default.path$=default.drive$+":"+default.path$+"\"
- ELSE
- default.path$=default.drive$+":\"
- ENDIF
- RETURN
- ' **********
- '
- > PROCEDURE standard.med.colors
- ' *** standard-colors for Medium resolution
- LOCAL n&,col$,r&,g&,b&
- RESTORE col.data
- FOR n&=0 TO 3
- READ col$
- r&=VAL(LEFT$(col$))
- g&=VAL(MID$(col$,2,1))
- b&=VAL(RIGHT$(col$))
- VSETCOLOR n&,r&,g&,b&
- NEXT n&
- '
- col.data:
- DATA 777,000,700,060
- RETURN
- ' **********
- '
- > PROCEDURE start.date.input
- ' *** input of date
- ' *** accepts different formats (day-month-year), e.g. :
- ' *** 1-6-'88 02-11-88 3.6.88 2/1/88 12 June 1988 9 Aug 88
- LOCAL x&,y&,date.input$,ok!,day$,day&,month.input$,month$,n&,month!,month&,year$,year&
- LOCAL new.date$
- PRINT " Date (dd.mm.yy) : ";
- x&=CRSCOL
- y&=CRSLIN
- ON ERROR GOSUB start.date.input.error
- '
- start.date.input:
- ' *** input of date
- ok!=TRUE
- FORM INPUT 18,date.input$
- ' *** day
- day.len&=VAL?(date.input$)
- IF day.len&>2
- IF INSTR(date.input$,".")=2
- day.len&=1
- ELSE
- IF INSTR(date.input$,".")=3
- day.len&=2
- ELSE
- ok!=FALSE
- ENDIF
- ENDIF
- ENDIF
- day$=LEFT$(date.input$,day.len&)
- day&=VAL(day$)
- IF day&>31 OR day&<1
- ok!=FALSE
- ENDIF
- ' *** mmonth
- month.input$=RIGHT$(date.input$,LEN(date.input$)-(day.len&+1))
- month.len&=VAL?(month.input$)
- IF month.len&=0
- month$=LEFT$(month.input$,3)
- month$=UPPER$(month$)
- start.month.data:
- DATA JAN,1,FEB,2,MAR,3,APR,4,MAY,5,JUN,6,JUL,7
- DATA AUG,8,SEP,9,OCT,10,NOV,11,DEC,12
- DIM date.input.month$(12),date.input.month&(12)
- RESTORE start.month.data
- FOR n&=1 TO 12
- READ date.input.month$(n&),date.input.month&(n&)
- NEXT n&
- FOR n&=1 TO 12
- IF date.input.month$(n&)=month$
- month!=TRUE
- month&=date.input.month&(n&)
- ENDIF
- NEXT n&
- ERASE date.input.month$()
- ERASE date.input.month&()
- IF NOT month!
- ok!=FALSE
- ENDIF
- ELSE
- month&=VAL(month.input$)
- ENDIF
- IF month&>12 OR month&<1
- ok!=FALSE
- ENDIF
- month$=STR$(month&)
- IF (month&=4 OR month&=6 OR month&=9 OR month&=11) AND day&>30
- ok!=FALSE
- ENDIF
- IF (month&=1 OR month&=3 OR month&=5 OR month&=7 OR month&=8 OR month&=10 OR month&=12) AND day&>31
- ok!=FALSE
- ENDIF
- ' *** year
- year$=RIGHT$(date.input$,2)
- IF VAL?(year$)<>2 OR INSTR(year$,".") OR VAL(year$)<88
- ok!=FALSE
- ENDIF
- year&=VAL(year$)
- IF month&=2
- IF day&>28
- IF (year& MOD 400=0) AND day&<>29
- ok!=FALSE
- ELSE
- IF year& MOD 100=0 AND (year& MOD 400<>0)
- ok!=FALSE
- ELSE
- IF (year& MOD 4=0) AND day&<>29
- ok!=FALSE
- ELSE
- IF (year& MOD 4<>0)
- ok!=FALSE
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ' *** print date
- IF NOT ok!
- PRINT CHR$(7);
- PRINT AT(x&,y&);STRING$(LEN(date.input$)," ");
- PRINT AT(x&,y&);"WRONG FORMAT !!";
- PAUSE 50
- PRINT AT(x&,y&);STRING$(18," ");
- PRINT AT(x&,y&);"";
- RBOX 22*8,10*16/fac&,58*8,15*16/fac&
- GOTO start.date.input
- ENDIF
- LET new.date$=day$+"."+month$+"."+year$
- SETTIME TIME$,new.date$
- ON ERROR
- RETURN
- ' ***
- > PROCEDURE start.date.input.error
- ' *** unexpected error
- ok!=FALSE
- ON ERROR GOSUB start.date.input.error
- RESUME NEXT
- RETURN
- ' **********
- '
- > PROCEDURE start.time.input
- ' *** input of time (seconds optional)
- ' *** <Return> = 00:00:00
- ' *** accepts different formats, e.g. :
- ' *** 12.40.10 1:30:25 20.45
- '
- LOCAL x&,y&,ok!,time.input$,hour.len&,hour$,minute.input$,minute.len&
- LOCAL minute$,second$,second.input$,second.len&,new.time$
- PRINT " Time (hh.mm[.ss]) : ";
- x&=CRSCOL
- y&=CRSLIN
- ON ERROR GOSUB start.time.input.error
- '
- start.time.input:
- ' *** input of time
- ok!=TRUE
- FORM INPUT 10,time.input$
- IF time.input$=""
- LET new.time$="00:00:00"
- GOTO start.time.exit
- ENDIF
- ' *** hour
- hour.len&=VAL?(time.input$)
- IF hour.len&>2
- IF INSTR(time.input$,".")=2
- hour.len&=1
- ELSE
- IF INSTR(time.input$,".")=3
- hour.len&=2
- ELSE
- ok!=FALSE
- ENDIF
- ENDIF
- ENDIF
- hour$=LEFT$(time.input$,hour.len&)
- IF VAL(hour$)>23
- ok!=FALSE
- ENDIF
- ' *** minutes
- LET minute.input$=RIGHT$(time.input$,LEN(time.input$)-(hour.len&+1))
- LET minute.len&=VAL?(minute.input$)
- IF minute.len&>2
- IF INSTR(minute.input$,".")=2
- LET minute.len&=1
- ELSE
- IF INSTR(minute.input$,".")=3
- LET minute.len&=2
- ELSE
- ok!=FALSE
- ENDIF
- ENDIF
- ENDIF
- LET minute$=LEFT$(minute.input$,minute.len&)
- IF VAL(minute$)>59
- ok!=FALSE
- ENDIF
- ' *** seconds
- IF minute.len&>=LEN(minute.input$)-1
- second$="0"
- ELSE
- second.input$=RIGHT$(minute.input$,LEN(minute.input$)-(minute.len&+1))
- second$=LEFT$(second.input$,2)
- IF VAL(second$)>59
- ok!=FALSE
- ENDIF
- ENDIF
- ' *** tijd
- IF NOT ok!
- PRINT CHR$(7);
- PRINT AT(x&,y&);STRING$(LEN(time.input$)," ");
- PRINT AT(x&,y&);"WRONG !!";
- PAUSE 50
- PRINT AT(x&,y&);STRING$(10," ");
- PRINT AT(x&,y&);"";
- RBOX 22*8,10*16/fac&,58*8,15*16/fac&
- GOTO start.time.input
- ENDIF
- LET new.time$=hour$+":"+minute$+":"+second$
- start.time.exit:
- SETTIME new.time$,DATE$
- ON ERROR
- RETURN
- ' ***
- > PROCEDURE start.time.input.error
- ' *** unexpected error
- ok!=FALSE
- ON ERROR GOSUB start.time.input.error
- RESUME NEXT
- RETURN
- ' **********
- '
- > PROCEDURE fileselect(path$,default$,txt$,VAR file$)
- ' *** use Fileselector with comment-line
- ' *** comment-line max. 38 characters in all resolutions
- ' *** uses Standard Function and Globals
- PRINT AT(1,3);@center$(txt$)
- GRAPHMODE 3
- DEFFILL 1,1 ! black
- BOUNDARY 0
- IF high.res!
- BOX 157,25,482,54
- PLOT 157,25
- PBOX 159,27,480,52
- ELSE IF med.res!
- BOX 157,12,482,27
- PLOT 157,12
- PBOX 160,14,479,24
- ELSE IF low.res!
- BOX 0,12,319,27
- PLOT 0,12
- PBOX 2,14,317,24
- ENDIF
- BOUNDARY 1
- GRAPHMODE 1
- FILESELECT path$,default$,file$
- RETURN
- ' **********
- '
- > PROCEDURE parse.filename(parse.name$,VAR drive$,path$,file$,ext$)
- ' *** return drive, path, filename (without extension !) and extension
- ' *** no checking for correct syntax
- ' *** example : "A:\GAMES\PLAY.GFA" returned as : A \GAMES\ PLAY GFA
- ' *** "A:\PLAY.GFA" returned as : A \ PLAY GFA
- LOCAL pos&,first&,last&,last!,search&,parse.file$
- '
- parse.name$=UPPER$(parse.name$)
- IF MID$(parse.name$,2,1)=":"
- drive$=LEFT$(parse.name$,1)
- ELSE
- drive$=CHR$(65+GEMDOS(&H19)) ! current drive
- ENDIF
- '
- pos&=1
- last!=FALSE
- last&=0
- first&=INSTR(1,parse.name$,"\")
- REPEAT
- search&=INSTR(pos&,parse.name$,"\")
- IF search&>0
- pos&=search&+1
- last&=search&
- ELSE
- last!=TRUE
- ENDIF
- UNTIL last!
- IF last&>0 ! backslash discovered
- path$=MID$(parse.name$,first&,last&-first&+1)
- parse.file$=MID$(parse.name$,last&+1)
- ELSE ! no '\'
- path$=""
- pos&=INSTR(1,parse.name$,":")
- IF pos&>0
- parse.file$=MID$(parse.name$,pos&+1)
- ELSE
- parse.file$=parse.name$
- ENDIF
- ENDIF
- pos&=INSTR(parse.file$,".")
- IF pos&>0 ! name with extension
- ext$=MID$(parse.file$,pos&+1)
- file$=LEFT$(parse.file$,pos&-1)
- ELSE ! name without extension
- ext$=""
- file$=parse.file$
- ENDIF
- RETURN
- ' **********
- '
-